package com.xx.servlte;

import com.alibaba.fastjson.JSON;
import com.xx.entity.Auction;
import com.xx.service.AuctionService;
import com.xx.service.Impl.AuctionServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet(name = "selectLikeServlet",urlPatterns = "/selectLikeServlet")
public class selectLikeServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String auctionName=request.getParameter("auctionName");
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html; charset=utf-8");
        AuctionService dao=new AuctionServiceImpl();
        List<Auction> list=dao.getLike(auctionName);
        String tmp= JSON.toJSONString(list);
        PrintWriter out=response.getWriter();
        out.println(tmp);
        out.flush();
        out.close();
    }
}
